package test.data;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import data.exception.DaoException;

public class DBTestServlet extends HttpServlet {

	private static final long	serialVersionUID	= 5222793251610509039L;

	public DBTestServlet() {
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		// Call test functions in the servlet environment
		try {

			System.out.println("=======================================");
			System.out.println("UserDao Testing:");
			UserDaoTest.test();

			System.out.println("=======================================");
			System.out.println("ComponentDao Testing:");
			ComponentDaoTest.test();

			System.out.println("=======================================");
			System.out.println("DaoTest Testing:");
			DaoTest.test();
			
		} catch (DaoException e) {
			System.out.println("Database Test FAILED!");
			e.printStackTrace();
		}
		
		PrintWriter out = response.getWriter();
	    out.println("Database Test Servlet End.");
	}

}
